import http from "@/api";

//自定义请求地址和参数的请求方法
export const httpPost = obj => {
  if (typeof obj != "string") {
    return http.post(obj.Url, obj.Params);
  }
  return http.post(obj);
};

export const httpPut = obj => {
  //若依java用了put，而且新增和修改的接口不一致
  if (typeof obj != "string") {
    return http.put(obj.Url, obj.Params);
  }
  return http.put(obj);
};

export const httpGet = obj => {
  //若依java用了get，获取数据详情时
  if (typeof obj != "string") {
    return http.get(obj.Url, obj.Params);
  }
  return http.get(obj);
};

export const httpDelete = url => {
  return http.delete(url);
};

export const httpDownload = obj => {
  return http.download(obj.url, obj.Params, {
    ...obj.config,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    }
  });
};
